package com.traffic.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.traffic.domain.PerSealDocument;
import com.traffic.service.IPerSealDocumentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 电子签章Controller
 * 
 * @author 郭世纪
 * @date 2024-12-08
 */
@RestController
@RequestMapping("/seal")
public class PerSealDocumentController extends BaseController
{
    @Autowired
    private IPerSealDocumentService perSealDocumentService;

    /**
     * 查询电子签章列表
     */
    @RequiresPermissions("document:seal:list")
    @GetMapping("/list")
    public TableDataInfo list(PerSealDocument perSealDocument)
    {
        startPage();
        List<PerSealDocument> list = perSealDocumentService.selectPerSealDocumentList(perSealDocument);
        return getDataTable(list);
    }

    /**
     * 导出电子签章列表
     */
    @RequiresPermissions("document:seal:export")
    @Log(title = "电子签章", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PerSealDocument perSealDocument)
    {
        List<PerSealDocument> list = perSealDocumentService.selectPerSealDocumentList(perSealDocument);
        ExcelUtil<PerSealDocument> util = new ExcelUtil<PerSealDocument>(PerSealDocument.class);
        util.exportExcel(response, list, "电子签章数据");
    }

    /**
     * 获取电子签章详细信息
     */
    @RequiresPermissions("document:seal:query")
    @GetMapping(value = "/{applicationId}")
    public AjaxResult getInfo(@PathVariable("applicationId") Long applicationId)
    {
        return success(perSealDocumentService.selectPerSealDocumentByApplicationId(applicationId));
    }

    /**
     * 新增电子签章
     */
    @RequiresPermissions("document:seal:add")
    @Log(title = "电子签章", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PerSealDocument perSealDocument)
    {
        return toAjax(perSealDocumentService.insertPerSealDocument(perSealDocument));
    }

    /**
     * 修改电子签章
     */
    @RequiresPermissions("document:seal:edit")
    @Log(title = "电子签章", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PerSealDocument perSealDocument)
    {
        return toAjax(perSealDocumentService.updatePerSealDocument(perSealDocument));
    }

    /**
     * 删除电子签章
     */
    @RequiresPermissions("document:seal:remove")
    @Log(title = "电子签章", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applicationIds}")
    public AjaxResult remove(@PathVariable Long[] applicationIds)
    {
        return toAjax(perSealDocumentService.deletePerSealDocumentByApplicationIds(applicationIds));
    }
}
